package test.netease.version2.chapter1.lesson1_1_3;

/**
 * @author zhangrui
 * @date 2020-04-24 19:10
 * @since 1.0
 */
public class StopThread implements Runnable{

    private int i = 0 , j = 0 , n = 0 ;

    @Override
    public void run() {

        for (int k = 0; k < 3; k++) {

            synchronized (this){
                ++i ;
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                ++j ;
            }
            ++n ;

        }

    }

    public void print(){
        System.out.println("i=" + i + ",j=" + j + ",n=" + n);
    }
}
